<?php /* SVN: $Id: $ */ ?>
<div class="blogComments index js-response">
    <ul class="filter-list-block clearfix">
        <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] ==  ConstMoreAction::Suspend) { echo 'class="active"';} ?>><span class="red-block" title="<?php echo __l('Suspended'); ?>"><?php echo $this->Html->link($this->Html->cInt($suspended,false).'<span>' .__l('Suspended'). '</span>', array('controller'=>'blog_comments','action'=>'index','filter_id' => ConstMoreAction::Suspend), array('escape' => false));?></span> </li>
        <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] ==  ConstMoreAction::Flagged) { echo 'class="active"';} ?>><span class="purple-block" title="<?php echo __l('Flagged'); ?>"><?php echo $this->Html->link($this->Html->cInt($system_flagged,false).'<span>' .__l('Flagged'). '</span>', array('controller'=>'blog_comments','action'=>'index','filter_id' => ConstMoreAction::Flagged), array('escape' => false));?></span> </li>
    </ul>
<div class="page-count-block clearfix">
	    <div class="grid_left">
	      <?php echo $this->element('paging_counter'); ?>
		</div>
		<div class="grid_left">
    <?php echo $this->Form->create('BlogComment', array('type' => 'get', 'class' => 'normal search-form clearfix', 'action'=>'index')); ?>
            <?php echo $this->Form->input('q', array('label' => __l('Keyword'))); ?>
			<?php echo $this->Form->submit(__l('Search'));?>
	<?php echo $this->Form->end(); ?>
		</div>
  </div>

    <?php echo $this->Form->create('BlogComment' , array('class' => 'normal','action' => 'update')); ?>
    <?php echo $this->Form->input('r', array('type' => 'hidden', 'value' => $this->request->url)); ?>
<table class="list">
    <tr>
        <th><?php echo __l('Select'); ?></th>
        <th class="actions"><?php echo __l('Actions');?></th>
        <th class="dl"><?php echo __l('Projects');?></th>
        <th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Comment'),'comment');?></div></th>        
        <th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Updates'), 'Blog.title');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('User'), 'User.username');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('IP'), 'Ip.ip');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Created'),'created');?></div></th>
    </tr>
<?php
if (!empty($blogComments)):

$i = 0;
foreach ($blogComments as $blogComment):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
	$status_class='';
	if($blogComment['BlogComment']['admin_suspend']):
		$status_class = ' js-checkbox-suspended';
	else:
		$status_class = ' js-checkbox-unsuspended';
	endif;
	if($blogComment['BlogComment']['is_system_flagged']):
		$status_class.= ' js-checkbox-flagged';
	else:
		$status_class.= ' js-checkbox-unflagged';
	endif;
?>
	<tr<?php echo $class;?>>
        <td><?php echo $this->Form->input('BlogComment.'.$blogComment['BlogComment']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$blogComment['BlogComment']['id'], 'label' => false, 'class' =>$status_class.' js-checkbox-list')); ?></td>
			<td class="actions dl">
            <div class="action-block">
                <span class="action-information-block">
                    <span class="action-left-block">&nbsp;&nbsp;</span>
                        <span class="action-center-block">
                            <span class="action-info">
                                <?php echo __l('Action');?>
                             </span>
                        </span>
                    </span>
                    <div class="action-inner-block">
                    <div class="action-inner-left-block">
                        <ul class="action-link clearfix">
                        <li><?php echo $this->Html->link(__l('Delete'), array('action' => 'delete', $blogComment['BlogComment']['id']), array('class' => 'delete js-delete', 'title' => __l('Delete')));?></li>
		<?php if($blogComment['BlogComment']['is_system_flagged']):?>
            <li>	<?php echo $this->Html->link(__l('Clear flag'), array('action' => 'admin_update_stats', $blogComment['BlogComment']['id'], 'flag' => 'deactivate'), array( 'class' => 'clear-flag js-delete', 'title' => __l('Clear flag')));?>
            </li>
        <?php else:?>
            <li>	<?php echo $this->Html->link(__l('Flag'), array('action' => 'admin_update_stats', $blogComment['BlogComment']['id'], 'flag' => 'active'), array('class' => 'flag js-delete', 'title' => __l('Flag')));?>
            </li>
        <?php endif;?>
        <?php if($blogComment['BlogComment']['admin_suspend']):?>
			<li><?php echo $this->Html->link(__l('Unsuspend'), array('action' => 'admin_update_stats', $blogComment['BlogComment']['id'], 'flag' => 'unsuspend'), array('class' => 'unsuspend js-delete', 'title' => __l('Unsuspend')));?>
			</li>
		<?php else:?>
			<li><?php echo $this->Html->link(__l('Suspend'), array('action' => 'admin_update_stats', $blogComment['BlogComment']['id'], 'flag' => 'suspend'), array('class' => 'suspend js-delete', 'title' => __l('Suspend')));?>
			</li>
		<?php endif;?>
	              		 </ul>
    					</div>
    					<div class="action-bottom-block"></div>
    				  </div>
              </div>
        </td>
        <td class="dl">
              <div class="clearfix">
              <?PHP
                         if($is_wallet_enabled)
                         {
                            $project_status = $blogComment['Blog']['Project']['ProjectStatus']['name'];
                         }
                           else
                           {
                             $project_status = str_replace("Refunded","Voided",$blogComment['Blog']['Project']['ProjectStatus']['name']);
                           }
                        ?>
                 <span title="<?php echo $this->Html->cText($project_status,false); ?>" class="project-atatus-info project-status-<?php echo $blogComment['Blog']['Project']['project_status_id'];?>">
                 <?php 
				 	echo $project_status_name = $this->Html->cText($project_status,false);
					if(!$project_status_name){
						echo '&nbsp;';
					}
				 ?>
                 </span>
		<?php echo $this->Html->link($this->Html->cText($this->Html->truncate($blogComment['Blog']['Project']['name'],90, array('ending' => '...')),false), array('controller'=> 'projects', 'action'=>'view', $blogComment['Blog']['Project']['slug'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($blogComment['Blog']['Project']['name'],false)));?>
                </div>
		</td>        
		<td class="dl">
			<span class="js-truncate {size:50}">
		       <?php echo $this->Html->truncate($this->Html->cText($blogComment['BlogComment']['comment'],false), 300);?>
			</span>
					<?php
				if($blogComment['BlogComment']['admin_suspend']):
					echo '<span class="pub-update round-3">'.__l('Admin Suspended').'</span>';
				endif;
				if($blogComment['BlogComment']['is_system_flagged']):
					echo '<span class="backeder round-3">'.__l('System Flagged').'</span>';
				endif;
				if(!empty($blogComment['BlogComment']['project_flag_count'])) :
					echo '<span class="backeder round-3">'.__l('User Flagged').'</span>';
				endif;

			?>
		</td>		
		<td class="dl">
		
		<?php echo $this->Html->link($this->Html->cText($blogComment['Blog']['title']), array('controller'=> 'blogs', 'action'=>'view', $blogComment['Blog']['slug'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($blogComment['Blog']['title'],false)));?></td>
		<td>
            <?php echo $this->Html->link($this->Html->cText($blogComment['User']['username'],false), array('controller'=> 'users', 'action'=>'view', $blogComment['User']['username'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($blogComment['User']['username'],false)));?>
        </td>
		<td class="dl">
                        <?php if(!empty($blogComment['Ip']['ip'])): ?>							  
                            <?php echo  $this->Html->link($blogComment['Ip']['ip'], array('controller' => 'users', 'action' => 'whois', $blogComment['Ip']['ip'], 'admin' => false), array('target' => '_blank', 'title' => 'whois '.$this->Html->cText($blogComment['Ip']['host'],false), 'escape' => false)); ?>
							<p>
							<?php 					
                            if(!empty($blogComment['Ip']['Country'])):
                                ?>
                                <span class="flags flag-<?php echo strtolower($blogComment['Ip']['Country']['iso2']); ?>" title ="<?php echo $blogComment['Ip']['Country']['name']; ?>">
									<?php echo $blogComment['Ip']['Country']['name']; ?>
								</span>
                                <?php
                            endif; 
							 if(!empty($blogComment['Ip']['City'])):
                            ?>             
                            <span> 	<?php echo $blogComment['Ip']['City']['name']; ?>    </span>
                            <?php endif; ?>
                            </p>
                        <?php else: ?>
							<?php echo __l('N/A'); ?>
						<?php endif; ?>    
		</td>		
		<td><?php echo $this->Html->cDateTimeHighlight($blogComment['BlogComment']['created']);?></td>
	</tr>
<?php
    endforeach;
else:
?>
	<tr>
		<td colspan="6" class="notice"><?php echo __l('No Project Update Comments available');?></td>
	</tr>
<?php
endif;
?>
</table>

<?php
if (!empty($blogComments)) : ?>
   <div class="clearfix">
	<div class="admin-select-block grid_left">
		<?php echo __l('Select:'); ?>
		<?php echo $this->Html->link(__l('All'), '#', array('class' => 'js-admin-select-all', 'title' => __l('All'))); ?>
		<?php echo $this->Html->link(__l('None'), '#', array('class' => 'js-admin-select-none', 'title' => __l('None'))); ?>
		<?php echo $this->Html->link(__l('Suspended'), '#', array('class' => 'js-admin-select-suspended', 'title' => __l('Suspended'))); ?>
		<?php echo $this->Html->link(__l('Flagged'), '#', array('class' => 'js-admin-select-flagged', 'title' => __l('Flagged'))); ?>
	</div>
	<div class="admin-checkbox-button grid_4 grid_left"><?php echo $this->Form->input('more_action_id', array('class' => 'js-admin-index-autosubmit', 'label' => false, 'empty' => __l('-- More actions --'))); ?></div>
   <div class="js-pagination grid_right">
        <?php echo $this->element('paging_links'); ?>
    </div>
    	</div>
    <div class="hide">
	    <?php echo $this->Form->submit('Submit'); ?>
    </div>
    <?php
endif;
echo $this->Form->end();
?>
</div>
